package com.pomr.model.equipmentstorage;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.health.PersonRecord;
import com.pomr.model.simstorage.SimStorageDetail;
import com.pomr.model.sys.User;
/**
 * 设备领用记录表
 * @author Administrator
 *
 */
@Entity
@Table(name="equipment_receive")
public class Receive implements Serializable{
	public String getEquipmentName() {
		return equipmentName;
	}

	public void setEquipmentName(String equipmentName) {
		this.equipmentName = equipmentName;
	}

	public String getEmanufacturerName() {
		return emanufacturerName;
	}

	public void setEmanufacturerName(String emanufacturerName) {
		this.emanufacturerName = emanufacturerName;
	}

	public String getEspecification() {
		return especification;
	}

	public void setEspecification(String especification) {
		this.especification = especification;
	}

	public String getEsN() {
		return esN;
	}

	public void setEsN(String esN) {
		this.esN = esN;
	}

	public String getNetworkName() {
		return networkName;
	}

	public void setNetworkName(String networkName) {
		this.networkName = networkName;
	}

	public String getSmanufacturerName() {
		return smanufacturerName;
	}

	public void setSmanufacturerName(String smanufacturerName) {
		this.smanufacturerName = smanufacturerName;
	}

	public String getSsN() {
		return ssN;
	}

	public void setSsN(String ssN) {
		this.ssN = ssN;
	}

	public DeviceMatch getMatch() {
		return match;
	}

	public void setMatch(DeviceMatch match) {
		this.match = match;
	}

	public Set<MonitoringData> getMonitors() {
		return monitors;
	}

	public void setMonitors(Set<MonitoringData> monitors) {
		this.monitors = monitors;
	}

	public String getRecordName() {
		return recordName;
	}

	public void setRecordName(String recordName) {
		this.recordName = recordName;
	}

	public Set<ReceiveRecipt> getReceipts() {
		return receipts;
	}

	public void setReceipts(Set<ReceiveRecipt> receipts) {
		this.receipts = receipts;
	}

	public Date getReceiveTime() {
		return receiveTime;
	}

	public void setReceiveTime(Date receiveTime) {
		this.receiveTime = receiveTime;
	}

	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}


	public PersonRecord getRecord() {
		return record;
	}

	public void setRecord(PersonRecord record) {
		this.record = record;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}



	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;//主键
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="match_id")
	private DeviceMatch match;//设备与sim卡匹配
	@Column(name="equipmentName",length=20)
	private String equipmentName;//设备名称
	@Column(name="emanufacturerName",length=20)
	private String emanufacturerName;//设备厂商
	@Column(name="especification",length=20)
	private String especification;//设备型号
	@Column(name="esN",length=30)
	private String esN;//设备sn编码
	@Column(name="networkName",length=20)
	private String networkName;//网络运营商
	@Column(name="smanufacturerName",length=20)
	private String smanufacturerName;//sim卡厂商
	@Column(name="ssN",length=30)
	private String ssN;//sim卡sn编码
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="record_id")
	private PersonRecord record;//个人档案主键
	
	@Formula("(select pr.name from person_record pr where pr.id=record_id)")
	private String recordName;
	@Column(name="status")
	private Integer status;//状态 1故障
	@Column(name="remark",length = 200)
	private String remark;//备注
	
	@ManyToOne
	@JoinColumn(name="createUser")
	private User createUser;//创建人员id
	
	
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 
	@Column(name="createTime")
	private Date createTime;//创建日期
	
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
	@Column(name="receiveTime")
	private Date receiveTime;//归还日期
	
	@JSONField(serialize = false)//禁止进行序列化 fastjson防止循环引用
	@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,targetEntity = ReceiveRecipt.class,orphanRemoval = true)//用户作为一方使用OneToMany注解      orphanRemoval是否自动删除receipts
    @JoinColumn(name = "receice_id")
	private Set<ReceiveRecipt> receipts;
	
	@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,targetEntity = MonitoringData.class,orphanRemoval = true)//用户作为一方使用OneToMany注解      orphanRemoval是否自动删除monitors
    @JoinColumn(name = "receice_id")
	private Set<MonitoringData> monitors;

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}
